package cn.luischen.controller.admin;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import javax.servlet.http.HttpServletRequest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import com.alibaba.fastjson.JSON;

import cn.luischen.controller.BaseController;
import cn.luischen.model.UserDomain;

/**
* The class <code>IndexControllerTest</code> contains tests for the class <code>{@link IndexController}</code>.
* Copyright (c) 2020
* 
* @generatedBy UnitSpirit at 2020-07-08 12:56:38
* @version 1.0.0
*/

@RunWith(PowerMockRunner.class)
public class IndexController_WGTest2 {

	/**
	* 测试方法初始化.
	* 
	* @throws Exception 
	*         if the initialization fails for some reason 
	*  
	* @generatedBy UnitSpirit at 2020-07-08 12:56:38
	*/
	@org.junit.Before
	public void setUp() throws Exception {

	}

  /**
  * @date 0707_204358_078_1
  * @method:saveProfile
  * @category auto generate by UnitSpirit  
  */
 //[{"afterReturning":true,"caseDate":"0707_204358_078_1","classModifiers":1,"className":"cn.luischen.controller.admin.IndexController","deep":0,"genericParameterTypes":["java.lang.String","java.lang.String","javax.servlet.http.HttpServletRequest","javax.servlet.http.HttpSession"],"interface":false,"methodModifiers":1,"methodName":"saveProfile","params":["admin12345","1034683568@qq.com",{},{}],"returnObj":"{\"code\":\"success\"}","returnType":"cn.luischen.utils.APIResponse","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.utils.APIResponse","deep":1,"genericParameterTypes":[],"interface":false,"methodModifiers":9,"methodName":"success","params":[],"returnObj":"{\"code\":\"success\"}","returnType":"cn.luischen.utils.APIResponse","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setEmail","params":["1034683568@qq.com"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setScreenName","params":["admin12345"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.service.log.impl.LogServiceImpl","deep":1,"genericParameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"addLog","params":["修改个人信息","{\"uid\":1,\"password\":\"111111\",\"email\":\"1034683568@qq.com\",\"screenName\":\"admin12345\"}","0:0:0:0:0:0:0:1",1],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1025,"className":"cn.luischen.controller.BaseController","deep":1,"genericParameterTypes":["javax.servlet.http.HttpServletRequest"],"interface":false,"methodModifiers":1,"methodName":"getUid","params":[{}],"returnObj":"1","returnType":"java.lang.Integer","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"org.apache.catalina.connector.Request","deep":1,"genericParameterTypes":[],"interface":false,"methodModifiers":1,"methodName":"getRemoteAddr","params":[],"returnObj":"\"0:0:0:0:0:0:0:1\"","returnType":"java.lang.String","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.service.user.impl.UserServiceImpl","deep":1,"genericParameterTypes":["cn.luischen.model.UserDomain"],"interface":false,"methodModifiers":1,"methodName":"updateUserInfo","params":[{"uid":1,"password":"111111","screenName":"admin12345","email":"1034683568@qq.com"}],"returnObj":"1","returnType":"int","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setEmail","params":["1034683568@qq.com"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setScreenName","params":["admin12345"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"setUid","params":[1],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":[],"interface":false,"methodModifiers":1,"methodName":"getUid","params":[],"returnObj":"1","returnType":"java.lang.Integer","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":[],"interface":false,"methodModifiers":1,"methodName":"<init>","params":[],"returnObj":"{\"password\":\"111111\"}","returnType":"cn.luischen.model.UserDomain","throw":false},{"afterReturning":true,"caseDate":"0707_204358_078","classModifiers":1025,"className":"cn.luischen.controller.BaseController","deep":1,"genericParameterTypes":["javax.servlet.http.HttpServletRequest"],"interface":false,"methodModifiers":1,"methodName":"user","params":[{}],"returnObj":"{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1234\",\"uid\":1,\"username\":\"admin\"}","returnType":"cn.luischen.model.UserDomain","throw":false}]
  
  @Test
	@PrepareForTest(BaseController.class)
  public void test_saveProfile_0707_204358_078_1() throws Throwable {

		cn.luischen.controller.admin.IndexController unitspirit_fixture = PowerMockito
				.mock(cn.luischen.controller.admin.IndexController.class);

		UserDomain cUserDomain = new UserDomain();
		cUserDomain.setUid(1);
		when(unitspirit_fixture.user(Mockito.any(HttpServletRequest.class)))
				.thenReturn(cUserDomain);

		when(unitspirit_fixture.saveProfile("1", "2", null, null)).thenCallRealMethod();
		cn.luischen.utils.APIResponse unitspirit_result = unitspirit_fixture.saveProfile("1", "2",
				null, null);
		System.out
				.println("unitspirit_check:test_saveProfile_0707_204358_078_1:" + JSON.toJSONString(unitspirit_result));
		cn.luischen.utils.APIResponse result_expected = JSON.parseObject("{\"code\":\"success\"}",
				cn.luischen.utils.APIResponse.class);
		assertEquals(JSON.toJSONString(result_expected), JSON.toJSONString(unitspirit_result));
  }
}